# coding=utf-8
# @Time: 2023/2/4 1:13
# @Author: zyg
# email: zhaoyiguang@lecent.cn
import yaml
from common.tools import get_project_path, sep


class GetConfig:
    def __init__(self):
        with open(get_project_path() + sep(["config", "environment.yaml"], add_sep_before=True), "r", encoding="utf-8") as env_file:
            # print(env_file.read())
            self.env = yaml.load(env_file, Loader=yaml.FullLoader)
            # print(self.env)

    def get_username_password(self, user):
        # return self.env["username"], self.env["password"]
        return self.env["user"][user]["username"], self.env["user"][user]["password"]

    def get_registe_data(self, user):
        return self.env["register"][user]["username"], self.env["register"][user]["password"], self.env["register"][user][
            "email"], self.env["register"][user]["phone"], self.env["register"][user]["radio"], self.env["register"][user]["school"]

    def get_mysql(self):
        db = self.env["mysql"]["db"]
        host = self.env["mysql"]["host"]
        user = self.env["mysql"]["user"]
        password = self.env["mysql"]["password"]
        port = self.env["mysql"]["port"]
        return db, host, user, password, port

    def get_mysql_config(self):
        return self.env["mysql"]

    def get_url(self):
        return self.env["url"]

    def get_force_wait_time(self):
        return self.env["force_wait_time"]


if __name__ == '__main__':
    print(GetConfig().get_username_password('zyg'))
    print(GetConfig().get_mysql())
    print(GetConfig().get_url())
    print(GetConfig().get_registe_data('user_a'))
    print(GetConfig().get_mysql_config())
